﻿using System;
using System.Data;
using System.Text;
using System.Data.OleDb;
using Maticsoft.DBUtility;//Please add references
namespace lcps.DAL
{
	/// <summary>
	/// 数据访问类:projectinfo
	/// </summary>
	public partial class projectinfo
	{
		public projectinfo()
		{}
        #region  Method
        public bool Isup(int id)
        {
           
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from projectinfo");
            strSql.Append(" where ID=@ID  and isup=0 and dealStorageDate is not null ");// "and  dealStorageDate is not null "将“办理出入库时间没有的去掉”
            OleDbParameter[] parameters = {
					new OleDbParameter("@ID", OleDbType.Integer,4)
			};
            parameters[0].Value = id;

            return DbHelperOleDb.Exists(strSql.ToString(), parameters);
        }
        //是否导出
        public bool setIsup(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set isup=1 ");
            strSql.Append(" where ID=" + id);
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId()
        {
            return DbHelperOleDb.GetMaxID("ID", "projectinfo");
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from projectinfo");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters = {
					new OleDbParameter("@ID", OleDbType.Integer,4)
			};
            parameters[0].Value = ID;

            return DbHelperOleDb.Exists(strSql.ToString(), parameters);
        }
        public bool Exists(lcps.Model.projectinfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from projectinfo");
            strSql.Append(" where proid=@proid and materiel=@materiel and nums=@nums");
            OleDbParameter[] parameters = {
					new OleDbParameter("@proid", OleDbType.VarChar,255),
                    new OleDbParameter("@materiel", OleDbType.VarChar,255),					
					new OleDbParameter("@nums", OleDbType.Single)
			};
            parameters[0].Value = model.proid;
            parameters[1].Value = model.materiel;
            parameters[2].Value = model.nums;
            return DbHelperOleDb.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(lcps.Model.projectinfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into projectinfo(");
            strSql.Append("[proid],[bidid],purchaseid,[usework],[projectname],[projecttype],[supplier],[materiel],[unit],[nums],[contractdate],[deliverydate],[confirmdate],[arrivaldate],[workdate],[drawingplandate],[drawingstate],[drawingsubmitdate],[drawingconfirmdate],[designstate],[majormaterielpurchase],[deviceproductionstate],[mothstate],[nextmoth],[planarrivedate],[coordinate],[remark],[realdate],[receivedname],[receivedphone],[suppliername],[supplierphone],[checkstate],[transactdate],[agent],[tableid],[isWarn])");
            strSql.Append(" values (");
            strSql.Append("@proid,@bidid,@purchaseid,@usework,@projectname,@projecttype,@supplier,@materiel,@unit,@nums,@contractdate,@deliverydate,@confirmdate,@arrivaldate,@workdate,@drawingplandate,@drawingstate,@drawingsubmitdate,@drawingconfirmdate,@designstate,@majormaterielpurchase,@deviceproductionstate,@mothstate,@nextmoth,@planarrivedate,@coordinate,@remark,@realdate,@receivedname,@receivedphone,@suppliername,@supplierphone,@checkstate,@transactdate,@agent,@tableid,@isWarn )");
            OleDbParameter[] parameters = {
					new OleDbParameter("@proid", OleDbType.VarChar,255),
					new OleDbParameter("@bidid", OleDbType.VarChar,255),
					new OleDbParameter("@purchaseid", OleDbType.VarChar,255),
					new OleDbParameter("@usework", OleDbType.VarChar,255),
					new OleDbParameter("@projectname", OleDbType.VarChar,255),
					new OleDbParameter("@projecttype", OleDbType.VarChar,255),
					new OleDbParameter("@supplier", OleDbType.VarChar,255),
					new OleDbParameter("@materiel", OleDbType.VarChar,255),
					new OleDbParameter("@unit", OleDbType.VarChar,255),
					new OleDbParameter("@nums", OleDbType.Single),
					new OleDbParameter("@contractdate", OleDbType.Date),
					new OleDbParameter("@deliverydate", OleDbType.Date),
                    new OleDbParameter("@confirmdate", OleDbType.Date),
					new OleDbParameter("@arrivaldate", OleDbType.Date),
					new OleDbParameter("@workdate", OleDbType.Date),
					new OleDbParameter("@drawingplandate", OleDbType.Date),
					new OleDbParameter("@drawingstate", OleDbType.VarChar,255),
					new OleDbParameter("@drawingsubmitdate", OleDbType.Date),
					new OleDbParameter("@drawingconfirmdate", OleDbType.Date),
					new OleDbParameter("@designstate", OleDbType.VarChar,255),
					new OleDbParameter("@majormaterielpurchase", OleDbType.VarChar,255),
					new OleDbParameter("@deviceproductionstate", OleDbType.VarChar,255),
					new OleDbParameter("@mothstate", OleDbType.VarChar,255),
					new OleDbParameter("@nextmoth", OleDbType.VarChar,255),
					new OleDbParameter("@planarrivedate", OleDbType.VarChar,255),
					new OleDbParameter("@coordinate", OleDbType.VarChar,255),
					new OleDbParameter("@remark", OleDbType.VarChar,0),
					new OleDbParameter("@realdate", OleDbType.Date),
					new OleDbParameter("@receivedname", OleDbType.VarChar,255),
					new OleDbParameter("@receivedphone", OleDbType.VarChar,255),
					new OleDbParameter("@suppliername", OleDbType.VarChar,255),
					new OleDbParameter("@supplierphone", OleDbType.VarChar,255),
					new OleDbParameter("@checkstate", OleDbType.VarChar,255),
					new OleDbParameter("@transactdate", OleDbType.Date),
					new OleDbParameter("@agent", OleDbType.VarChar,255),
					new OleDbParameter("@tableid", OleDbType.Integer,4),
                    //new OleDbParameter("@dealStorageDate", OleDbType.Date),
                    new OleDbParameter("@isWarn", OleDbType.Integer,4)};
            parameters[0].Value = model.proid;
            parameters[1].Value = model.bidid;
            parameters[2].Value = model.purchaseid;
            parameters[3].Value = model.usework;
            parameters[4].Value = model.projectname;
            parameters[5].Value = model.projecttype;
            parameters[6].Value = model.supplier;
            parameters[7].Value = model.materiel;
            parameters[8].Value = model.unit;
            parameters[9].Value = model.nums;
            parameters[10].Value = model.contractdate;
            parameters[11].Value = model.deliverydate;
            parameters[12].Value = model.confirmdate;
            parameters[13].Value = model.arrivaldate;
            parameters[14].Value = model.workdate;
            parameters[15].Value = model.drawingplandate;
            parameters[16].Value = model.drawingstate;
            parameters[17].Value = model.drawingsubmitdate;
            parameters[18].Value = model.drawingconfirmdate;
            parameters[19].Value = model.designstate;
            parameters[20].Value = model.majormaterielpurchase;
            parameters[21].Value = model.deviceproductionstate;
            parameters[22].Value = model.mothstate;
            parameters[23].Value = model.nextmoth;
            parameters[24].Value = model.planarrivedate;
            parameters[25].Value = model.coordinate;
            parameters[26].Value = model.remark;
            parameters[27].Value = model.realdate;
            parameters[28].Value = model.receivedname;
            parameters[29].Value = model.receivedphone;
            parameters[30].Value = model.suppliername;
            parameters[31].Value = model.supplierphone;
            parameters[32].Value = model.checkstate;
            parameters[33].Value = model.transactdate;
            parameters[34].Value = model.agent;
            parameters[35].Value = model.tableid;
            //parameters[36].Value = model.dealStorageDate;
            parameters[36].Value = model.isWarn;

            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(lcps.Model.projectinfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set ");
            strSql.Append("proid=@proid,");
            strSql.Append("bidid=@bidid,");
            strSql.Append("purchaseid=@purchaseid,");
            strSql.Append("usework=@usework,");
            strSql.Append("projectname=@projectname,");
            strSql.Append("projecttype=@projecttype,");
            strSql.Append("supplier=@supplier,");
            strSql.Append("materiel=@materiel,");
            strSql.Append("unit=@unit,");
            strSql.Append("nums=@nums,");
            strSql.Append("contractdate=@contractdate,");
            strSql.Append("deliverydate=@deliverydate,");
            strSql.Append("arrivaldate=@arrivaldate,");
            strSql.Append("workdate=@workdate,");
            strSql.Append("drawingplandate=@drawingplandate,");
            strSql.Append("drawingstate=@drawingstate,");
            strSql.Append("drawingsubmitdate=@drawingsubmitdate,");
            strSql.Append("drawingconfirmdate=@drawingconfirmdate,");
            strSql.Append("designstate=@designstate,");
            strSql.Append("majormaterielpurchase=@majormaterielpurchase,");
            strSql.Append("deviceproductionstate=@deviceproductionstate,");
            strSql.Append("mothstate=@mothstate,");
            strSql.Append("nextmoth=@nextmoth,");
            strSql.Append("planarrivedate=@planarrivedate,");
            strSql.Append("coordinate=@coordinate,");
            strSql.Append("remark=@remark,");
            strSql.Append("realdate=@realdate,");
            strSql.Append("receivedname=@receivedname,");
            strSql.Append("receivedphone=@receivedphone,");
            strSql.Append("suppliername=@suppliername,");
            strSql.Append("supplierphone=@supplierphone,");
            strSql.Append("checkstate=@checkstate,");
            strSql.Append("transactdate=@transactdate,");
            strSql.Append("agent=@agent,");
            strSql.Append("[tableid]=@tableid,");
            strSql.Append("[dealStorageDate]=@dealStorageDate,");
            strSql.Append("[isWarn]=@isWarn ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters = {
					new OleDbParameter("@proid", OleDbType.VarChar,255),
					new OleDbParameter("@bidid", OleDbType.VarChar,255),
					new OleDbParameter("@purchaseid", OleDbType.VarChar,255),
					new OleDbParameter("@usework", OleDbType.VarChar,255),
					new OleDbParameter("@projectname", OleDbType.VarChar,255),
					new OleDbParameter("@projecttype", OleDbType.VarChar,255),
					new OleDbParameter("@supplier", OleDbType.VarChar,255),
					new OleDbParameter("@materiel", OleDbType.VarChar,255),
					new OleDbParameter("@unit", OleDbType.VarChar,255),
					new OleDbParameter("@nums", OleDbType.Single),
					new OleDbParameter("@contractdate", OleDbType.Date),
					new OleDbParameter("@deliverydate", OleDbType.Date),
					new OleDbParameter("@arrivaldate", OleDbType.Date),
					new OleDbParameter("@workdate", OleDbType.Date),
					new OleDbParameter("@drawingplandate", OleDbType.Date),
					new OleDbParameter("@drawingstate", OleDbType.VarChar,255),
					new OleDbParameter("@drawingsubmitdate", OleDbType.Date),
					new OleDbParameter("@drawingconfirmdate", OleDbType.Date),
					new OleDbParameter("@designstate", OleDbType.VarChar,255),
					new OleDbParameter("@majormaterielpurchase", OleDbType.VarChar,255),
					new OleDbParameter("@deviceproductionstate", OleDbType.VarChar,255),
					new OleDbParameter("@mothstate", OleDbType.VarChar,255),
					new OleDbParameter("@nextmoth", OleDbType.VarChar,255),
					new OleDbParameter("@planarrivedate", OleDbType.Date),
					new OleDbParameter("@coordinate", OleDbType.VarChar,255),
					new OleDbParameter("@remark", OleDbType.VarChar,0),
					new OleDbParameter("@realdate", OleDbType.Date),
					new OleDbParameter("@receivedname", OleDbType.VarChar,255),
					new OleDbParameter("@receivedphone", OleDbType.VarChar,255),
					new OleDbParameter("@suppliername", OleDbType.VarChar,255),
					new OleDbParameter("@supplierphone", OleDbType.VarChar,255),
					new OleDbParameter("@checkstate", OleDbType.VarChar,255),
					new OleDbParameter("@transactdate", OleDbType.Date),
					new OleDbParameter("@agent", OleDbType.VarChar,255),
					new OleDbParameter("@tableid", OleDbType.Integer,4),
                    new OleDbParameter("@dealStorageDate", OleDbType.Date),
                    new OleDbParameter("@isWarn", OleDbType.Integer,4),
					new OleDbParameter("@ID", OleDbType.Integer,4)
                   };
            parameters[0].Value = model.proid;
            parameters[1].Value = model.bidid;
            parameters[2].Value = model.purchaseid;
            parameters[3].Value = model.usework;
            parameters[4].Value = model.projectname;
            parameters[5].Value = model.projecttype;
            parameters[6].Value = model.supplier;
            parameters[7].Value = model.materiel;
            parameters[8].Value = model.unit;
            parameters[9].Value = model.nums;
            parameters[10].Value = model.contractdate;
            parameters[11].Value = model.deliverydate;
            parameters[12].Value = model.arrivaldate;
            parameters[13].Value = model.workdate;
            parameters[14].Value = model.drawingplandate;
            parameters[15].Value = model.drawingstate;
            parameters[16].Value = model.drawingsubmitdate;
            parameters[17].Value = model.drawingconfirmdate;
            parameters[18].Value = model.designstate;
            parameters[19].Value = model.majormaterielpurchase;
            parameters[20].Value = model.deviceproductionstate;
            parameters[21].Value = model.mothstate;
            parameters[22].Value = model.nextmoth;
            parameters[23].Value = model.planarrivedate;
            parameters[24].Value = model.coordinate;
            parameters[25].Value = model.remark;
            parameters[26].Value = model.realdate;
            parameters[27].Value = model.receivedname;
            parameters[28].Value = model.receivedphone;
            parameters[29].Value = model.suppliername;
            parameters[30].Value = model.supplierphone;
            parameters[31].Value = model.checkstate;
            parameters[32].Value = model.transactdate;
            parameters[33].Value = model.agent;
            parameters[34].Value = model.tableid;
            parameters[35].Value = model.dealStorageDate;
            parameters[36].Value = model.isWarn;
            parameters[37].Value = model.ID;
            

            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool UpdateGV(lcps.Model.projectinfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set ");
            strSql.Append("proid=@proid,");
            strSql.Append("bidid=@bidid,");
            strSql.Append("purchaseid=@purchaseid,");
            strSql.Append("usework=@usework,");
            strSql.Append("projectname=@projectname,");
            strSql.Append("projecttype=@projecttype,");
            strSql.Append("supplier=@supplier,");
            strSql.Append("materiel=@materiel,");
            strSql.Append("unit=@unit,");
            strSql.Append("nums=@nums,");
            strSql.Append("contractdate=@contractdate,");
            strSql.Append("deliverydate=@deliverydate,");
            strSql.Append("confirmdate=@confirmdate,");
            strSql.Append("arrivaldate=@arrivaldate,");
            strSql.Append("workdate=@workdate,");
            strSql.Append("drawingplandate=@drawingplandate,");
            strSql.Append("drawingstate=@drawingstate,");
            strSql.Append("drawingsubmitdate=@drawingsubmitdate,");
            strSql.Append("drawingconfirmdate=@drawingconfirmdate,");
            strSql.Append("designstate=@designstate,");
            strSql.Append("majormaterielpurchase=@majormaterielpurchase,");
            strSql.Append("deviceproductionstate=@deviceproductionstate,");
            strSql.Append("mothstate=@mothstate,");
            strSql.Append("nextmoth=@nextmoth,");
            strSql.Append("planarrivedate=@planarrivedate,");
            strSql.Append("coordinate=@coordinate,");
            strSql.Append("remark=@remark,");
            strSql.Append("realdate=@realdate,");
            strSql.Append("receivedname=@receivedname,");
            strSql.Append("receivedphone=@receivedphone,");
            strSql.Append("suppliername=@suppliername,");
            strSql.Append("supplierphone=@supplierphone,");
            strSql.Append("checkstate=@checkstate,");
            strSql.Append("transactdate=@transactdate,");
            strSql.Append("[dealStorageDate]=@dealStorageDate,");
            strSql.Append("[isWarn]=@isWarn");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters = {
					new OleDbParameter("@proid", OleDbType.VarChar,255),
					new OleDbParameter("@bidid", OleDbType.VarChar,255),
					new OleDbParameter("@purchaseid", OleDbType.VarChar,255),
					new OleDbParameter("@usework", OleDbType.VarChar,255),
					new OleDbParameter("@projectname", OleDbType.VarChar,255),
					new OleDbParameter("@projecttype", OleDbType.VarChar,255),
					new OleDbParameter("@supplier", OleDbType.VarChar,255),
					new OleDbParameter("@materiel", OleDbType.VarChar,255),
					new OleDbParameter("@unit", OleDbType.VarChar,255),
					new OleDbParameter("@nums", OleDbType.Single),
					new OleDbParameter("@contractdate", OleDbType.Date),
					new OleDbParameter("@deliverydate", OleDbType.Date),
                    new OleDbParameter("@confirmdate", OleDbType.Date),
					new OleDbParameter("@arrivaldate", OleDbType.Date),
					new OleDbParameter("@workdate", OleDbType.Date),
					new OleDbParameter("@drawingplandate", OleDbType.Date),
					new OleDbParameter("@drawingstate", OleDbType.VarChar,255),
					new OleDbParameter("@drawingsubmitdate", OleDbType.Date),
					new OleDbParameter("@drawingconfirmdate", OleDbType.Date),
					new OleDbParameter("@designstate", OleDbType.VarChar,255),
					new OleDbParameter("@majormaterielpurchase", OleDbType.VarChar,255),
					new OleDbParameter("@deviceproductionstate", OleDbType.VarChar,255),
					new OleDbParameter("@mothstate", OleDbType.VarChar,255),
					new OleDbParameter("@nextmoth", OleDbType.VarChar,255),
					new OleDbParameter("@planarrivedate", OleDbType.VarChar,255),
					new OleDbParameter("@coordinate", OleDbType.VarChar,255),
					new OleDbParameter("@remark", OleDbType.VarChar,0),
					new OleDbParameter("@realdate", OleDbType.Date),
					new OleDbParameter("@receivedname", OleDbType.VarChar,255),
					new OleDbParameter("@receivedphone", OleDbType.VarChar,255),
					new OleDbParameter("@suppliername", OleDbType.VarChar,255),
					new OleDbParameter("@supplierphone", OleDbType.VarChar,255),
					new OleDbParameter("@checkstate", OleDbType.VarChar,255),
					new OleDbParameter("@transactdate", OleDbType.Date),
					new OleDbParameter("@dealStorageDate", OleDbType.Date),
                    new OleDbParameter("@isWarn", OleDbType.Integer,4),
					new OleDbParameter("@ID", OleDbType.Integer,4)
                    };
            parameters[0].Value = model.proid;
            parameters[1].Value = model.bidid;
            parameters[2].Value = model.purchaseid;
            parameters[3].Value = model.usework;
            parameters[4].Value = model.projectname;
            parameters[5].Value = model.projecttype;
            parameters[6].Value = model.supplier;
            parameters[7].Value = model.materiel;
            parameters[8].Value = model.unit;
            parameters[9].Value = model.nums;
            parameters[10].Value = model.contractdate;
            parameters[11].Value = model.deliverydate;
            parameters[12].Value = model.confirmdate;
            parameters[13].Value = model.arrivaldate;
            parameters[14].Value = model.workdate;
            parameters[15].Value = model.drawingplandate;
            parameters[16].Value = model.drawingstate;
            parameters[17].Value = model.drawingsubmitdate;
            parameters[18].Value = model.drawingconfirmdate;
            parameters[19].Value = model.designstate;
            parameters[20].Value = model.majormaterielpurchase;
            parameters[21].Value = model.deviceproductionstate;
            parameters[22].Value = model.mothstate;
            parameters[23].Value = model.nextmoth;
            parameters[24].Value = model.planarrivedate;
            parameters[25].Value = model.coordinate;
            parameters[26].Value = model.remark;
            parameters[27].Value = model.realdate;
            parameters[28].Value = model.receivedname;
            parameters[29].Value = model.receivedphone;
            parameters[30].Value = model.suppliername;
            parameters[31].Value = model.supplierphone;
            parameters[32].Value = model.checkstate;
            parameters[33].Value = model.transactdate;
            parameters[34].Value = model.dealStorageDate;
            parameters[35].Value = model.isWarn;
            parameters[36].Value = model.ID;
           

            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from projectinfo ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters = {
					new OleDbParameter("@ID", OleDbType.Integer,4)
			};
            parameters[0].Value = ID;

            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string IDlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from projectinfo ");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool setstatusList(string IDlist, string sta)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set deviceproductionstate='" + sta + "'");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool setbzList(string IDlist, string sta)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set remark='" + sta + "'");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool setcoordinateList(string IDlist, string sta)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set coordinate='" + sta + "'");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool setreceivednameList(string IDlist, string sta)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set receivedname='" + sta + "'");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool setrealtimeList(string IDlist, string sta)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set realdate='" + sta + "'");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool setplanarrivedateList(string IDlist, string sta)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set planarrivedate='" + sta + "'");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        //办理出入库时间
        public bool setdealStorageDate(string IDlist, string sta)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set dealStorageDate='" + sta + "'");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        //确定交货期
        public bool setconfirmdate(string IDlist, string sta)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set confirmdate='" + sta + "'");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        //是否预警
        public bool setIsWarn(string IDlist, string sta)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update projectinfo set iswarn=" + sta + "");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 批量删除数据根据条件 ，条件为空全表删除！
        /// </summary>
        public bool DeleteByWhere(string where)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from projectinfo ");
            if (!string.IsNullOrEmpty(where))
            {
                strSql.Append(where);
            }
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lcps.Model.projectinfo GetModel(int ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,proid,bidid,purchaseid,usework,projectname,projecttype,supplier,materiel,unit,nums,contractdate,deliverydate,arrivaldate,workdate,drawingplandate,drawingstate,drawingsubmitdate,drawingconfirmdate,designstate,majormaterielpurchase,deviceproductionstate,mothstate,nextmoth,planarrivedate,coordinate,remark,realdate,receivedname,receivedphone,suppliername,supplierphone,checkstate,transactdate,agent,tableid,dealStorageDate,isWarn from projectinfo ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters = {
					new OleDbParameter("@ID", OleDbType.Integer,4)
			};
            parameters[0].Value = ID;

            lcps.Model.projectinfo model = new lcps.Model.projectinfo();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["proid"] != null && ds.Tables[0].Rows[0]["proid"].ToString() != "")
                {
                    model.proid = ds.Tables[0].Rows[0]["proid"].ToString();
                }
                if (ds.Tables[0].Rows[0]["bidid"] != null && ds.Tables[0].Rows[0]["bidid"].ToString() != "")
                {
                    model.bidid = ds.Tables[0].Rows[0]["bidid"].ToString();
                }
                if (ds.Tables[0].Rows[0]["purchaseid"] != null && ds.Tables[0].Rows[0]["purchaseid"].ToString() != "")
                {
                    model.purchaseid = ds.Tables[0].Rows[0]["purchaseid"].ToString();
                }
                if (ds.Tables[0].Rows[0]["usework"] != null && ds.Tables[0].Rows[0]["usework"].ToString() != "")
                {
                    model.usework = ds.Tables[0].Rows[0]["usework"].ToString();
                }
                if (ds.Tables[0].Rows[0]["projectname"] != null && ds.Tables[0].Rows[0]["projectname"].ToString() != "")
                {
                    model.projectname = ds.Tables[0].Rows[0]["projectname"].ToString();
                }
                if (ds.Tables[0].Rows[0]["projecttype"] != null && ds.Tables[0].Rows[0]["projecttype"].ToString() != "")
                {
                    model.projecttype = ds.Tables[0].Rows[0]["projecttype"].ToString();
                }
                if (ds.Tables[0].Rows[0]["supplier"] != null && ds.Tables[0].Rows[0]["supplier"].ToString() != "")
                {
                    model.supplier = ds.Tables[0].Rows[0]["supplier"].ToString();
                }
                if (ds.Tables[0].Rows[0]["materiel"] != null && ds.Tables[0].Rows[0]["materiel"].ToString() != "")
                {
                    model.materiel = ds.Tables[0].Rows[0]["materiel"].ToString();
                }
                if (ds.Tables[0].Rows[0]["unit"] != null && ds.Tables[0].Rows[0]["unit"].ToString() != "")
                {
                    model.unit = ds.Tables[0].Rows[0]["unit"].ToString();
                }
                if (ds.Tables[0].Rows[0]["nums"] != null && ds.Tables[0].Rows[0]["nums"].ToString() != "")
                {
                    model.nums = float.Parse(ds.Tables[0].Rows[0]["nums"].ToString());
                }
                if (ds.Tables[0].Rows[0]["contractdate"] != null && ds.Tables[0].Rows[0]["contractdate"].ToString() != "")
                {
                    model.contractdate = DateTime.Parse(ds.Tables[0].Rows[0]["contractdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["deliverydate"] != null && ds.Tables[0].Rows[0]["deliverydate"].ToString() != "")
                {
                    model.deliverydate = DateTime.Parse(ds.Tables[0].Rows[0]["deliverydate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["arrivaldate"] != null && ds.Tables[0].Rows[0]["arrivaldate"].ToString() != "")
                {
                    model.arrivaldate = DateTime.Parse(ds.Tables[0].Rows[0]["arrivaldate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["workdate"] != null && ds.Tables[0].Rows[0]["workdate"].ToString() != "")
                {
                    model.workdate = DateTime.Parse(ds.Tables[0].Rows[0]["workdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["drawingplandate"] != null && ds.Tables[0].Rows[0]["drawingplandate"].ToString() != "")
                {
                    model.drawingplandate = DateTime.Parse(ds.Tables[0].Rows[0]["drawingplandate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["drawingstate"] != null && ds.Tables[0].Rows[0]["drawingstate"].ToString() != "")
                {
                    model.drawingstate = ds.Tables[0].Rows[0]["drawingstate"].ToString();
                }
                if (ds.Tables[0].Rows[0]["drawingsubmitdate"] != null && ds.Tables[0].Rows[0]["drawingsubmitdate"].ToString() != "")
                {
                    model.drawingsubmitdate = DateTime.Parse(ds.Tables[0].Rows[0]["drawingsubmitdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["drawingconfirmdate"] != null && ds.Tables[0].Rows[0]["drawingconfirmdate"].ToString() != "")
                {
                    model.drawingconfirmdate = DateTime.Parse(ds.Tables[0].Rows[0]["drawingconfirmdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["designstate"] != null && ds.Tables[0].Rows[0]["designstate"].ToString() != "")
                {
                    model.designstate = ds.Tables[0].Rows[0]["designstate"].ToString();
                }
                if (ds.Tables[0].Rows[0]["majormaterielpurchase"] != null && ds.Tables[0].Rows[0]["majormaterielpurchase"].ToString() != "")
                {
                    model.majormaterielpurchase = ds.Tables[0].Rows[0]["majormaterielpurchase"].ToString();
                }
                if (ds.Tables[0].Rows[0]["deviceproductionstate"] != null && ds.Tables[0].Rows[0]["deviceproductionstate"].ToString() != "")
                {
                    model.deviceproductionstate = ds.Tables[0].Rows[0]["deviceproductionstate"].ToString();
                }
                if (ds.Tables[0].Rows[0]["mothstate"] != null && ds.Tables[0].Rows[0]["mothstate"].ToString() != "")
                {
                    model.mothstate = ds.Tables[0].Rows[0]["mothstate"].ToString();
                }
                if (ds.Tables[0].Rows[0]["nextmoth"] != null && ds.Tables[0].Rows[0]["nextmoth"].ToString() != "")
                {
                    model.nextmoth = ds.Tables[0].Rows[0]["nextmoth"].ToString();
                }
                if (ds.Tables[0].Rows[0]["planarrivedate"] != null && ds.Tables[0].Rows[0]["planarrivedate"].ToString() != "")
                {
                    model.planarrivedate = ds.Tables[0].Rows[0]["planarrivedate"].ToString();
                }
                if (ds.Tables[0].Rows[0]["coordinate"] != null && ds.Tables[0].Rows[0]["coordinate"].ToString() != "")
                {
                    model.coordinate = ds.Tables[0].Rows[0]["coordinate"].ToString();
                }
                if (ds.Tables[0].Rows[0]["remark"] != null && ds.Tables[0].Rows[0]["remark"].ToString() != "")
                {
                    model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["realdate"] != null && ds.Tables[0].Rows[0]["realdate"].ToString() != "")
                {
                    model.realdate = DateTime.Parse(ds.Tables[0].Rows[0]["realdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["receivedname"] != null && ds.Tables[0].Rows[0]["receivedname"].ToString() != "")
                {
                    model.receivedname = ds.Tables[0].Rows[0]["receivedname"].ToString();
                }
                if (ds.Tables[0].Rows[0]["receivedphone"] != null && ds.Tables[0].Rows[0]["receivedphone"].ToString() != "")
                {
                    model.receivedphone = ds.Tables[0].Rows[0]["receivedphone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["suppliername"] != null && ds.Tables[0].Rows[0]["suppliername"].ToString() != "")
                {
                    model.suppliername = ds.Tables[0].Rows[0]["suppliername"].ToString();
                }
                if (ds.Tables[0].Rows[0]["supplierphone"] != null && ds.Tables[0].Rows[0]["supplierphone"].ToString() != "")
                {
                    model.supplierphone = ds.Tables[0].Rows[0]["supplierphone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["checkstate"] != null && ds.Tables[0].Rows[0]["checkstate"].ToString() != "")
                {
                    model.checkstate = ds.Tables[0].Rows[0]["checkstate"].ToString();
                }
                if (ds.Tables[0].Rows[0]["transactdate"] != null && ds.Tables[0].Rows[0]["transactdate"].ToString() != "")
                {
                    model.transactdate = DateTime.Parse(ds.Tables[0].Rows[0]["transactdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["agent"] != null && ds.Tables[0].Rows[0]["agent"].ToString() != "")
                {
                    model.agent = ds.Tables[0].Rows[0]["agent"].ToString();
                }
                if (ds.Tables[0].Rows[0]["tableid"] != null && ds.Tables[0].Rows[0]["tableid"].ToString() != "")
                {
                    model.tableid = int.Parse(ds.Tables[0].Rows[0]["tableid"].ToString());
                }
                //办理出入库时间
                if (ds.Tables[0].Rows[0]["dealStorageDate"] != null && ds.Tables[0].Rows[0]["dealStorageDate"].ToString() != "")
                {
                    model.dealStorageDate = DateTime.Parse(ds.Tables[0].Rows[0]["dealStorageDate"].ToString());
                }
                //是否预警
                if (ds.Tables[0].Rows[0]["isWarn"] != null && ds.Tables[0].Rows[0]["isWarn"].ToString() != "")
                {
                    model.isWarn = int.Parse(ds.Tables[0].Rows[0]["isWarn"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,proid,bidid,purchaseid,usework,projectname,projecttype,supplier,materiel,unit,nums,contractdate,deliverydate,confirmdate,arrivaldate,workdate,drawingplandate,drawingstate,drawingsubmitdate,drawingconfirmdate,designstate,majormaterielpurchase,deviceproductionstate,mothstate,nextmoth,planarrivedate,coordinate,remark,realdate,receivedname,receivedphone,suppliername,supplierphone,checkstate,transactdate,agent,tableid,dealStorageDate,isWarn ");
            strSql.Append(" FROM projectinfo ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperOleDb.Query(strSql.ToString());
        }

        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM projectinfo ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.ID desc");
            }
            strSql.Append(")AS Row, T.*  from projectinfo T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperOleDb.Query(strSql.ToString());
        }

        /*
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            OleDbParameter[] parameters = {
                    new OleDbParameter("@tblName", OleDbType.VarChar, 255),
                    new OleDbParameter("@fldName", OleDbType.VarChar, 255),
                    new OleDbParameter("@PageSize", OleDbType.Integer),
                    new OleDbParameter("@PageIndex", OleDbType.Integer),
                    new OleDbParameter("@IsReCount", OleDbType.Boolean),
                    new OleDbParameter("@OrderType", OleDbType.Boolean),
                    new OleDbParameter("@strWhere", OleDbType.VarChar,1000),
                    };
            parameters[0].Value = "projectinfo";
            parameters[1].Value = "ID";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;	
            return DbHelperOleDb.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        }*/

        #endregion  Method
	}
}

